﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebSysCore;
using WebSysCore.Helpers;

namespace HSchSchedule.FrontPage
{
    public partial class AddNews : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void Insert()
        {
            New enNew = new New();
            enNew.NewsContent = txtContent.Text.Trim();
            enNew.Title = txtTitle.Text.Trim();
            enNew.Sumary = txtSumary.Text.Trim();
            enNew.Date = DateTime.Now;
            enNew.Image = "";
            bool ok = true;
            string er = "";
            ok = ValidateHelp.ValidateNews(enNew, out er);
            if (!ok)
            {
                lblError.Text = er;

            }
            else
            {
                DataBase.AddNews(enNew);
                Response.Redirect("~/FrontPage/NewsManage.aspx");
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Insert();
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/FrontPage/NewsManage.aspx");
        }

    }
}
